<!DOCTYPE html>
<html class="x-admin-sm">
    
    <head>
        <meta charset="UTF-8">
        <title>修改管理员密码</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <link rel="stylesheet" href="../css/font.css">
        <link rel="stylesheet" href="../css/xadmin.css">
        <script src="../lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="../js/xadmin.js"></script>
        <script type="text/javascript" src="../lib/layui-v2.6.4/layui/layui.js"></script>
        <script type="text/javascript" src="../assets/js/jquery-1.8.3.min.js"></script>
    </head>
    <body>
    <a href="index.html" >123</a>
        <div class="layui-fluid" style="margin-left:30% ;margin-top: 5%">

            <div class="layui-form-item" style="display:none">
                <label  class="layui-form-label">Id：</label>
                <div class="layui-input-inline">
                    <input type="text"   id="aid"  readonly="readonly" name="username"  class="layui-input" ></div>
            </div>
            <div class="layui-row">
                    <div class="layui-form-item">
                        <label  class="layui-form-label">姓名：</label>
                        <div class="layui-input-inline">
                            <input type="text" readonly="readonly" id="aname" name="username"  class="layui-input"></div>
                    </div>
                <div class="layui-form-item">
                    <label  class="layui-form-label">性别：</label>
                    <div class="layui-input-inline">
                        <input type="text" id="asex" name="username"  class="layui-input"></div>
                </div>
                <div class="layui-form-item">
                    <label  class="layui-form-label">年龄：</label>
                    <div class="layui-input-inline">
                        <input type="text" id="aage" name="username"  class="layui-input"></div>
                </div>
                <div class="layui-form-item">
                    <label  class="layui-form-label">手机号：</label>
                    <div class="layui-input-inline">
                        <input type="text" id="aphone" name="username"  class="layui-input"></div>
                </div>
                <div class="layui-form-item">
                    <label  class="layui-form-label">账号状态：</label>
                    <div class="layui-input-inline">
                        <input type="text" id="type" name="username"  class="layui-input"></div>
                </div>
                <div class="layui-form-item">
                    <label  class="layui-form-label"></label>
                    <button id="butt" class="layui-btn" lay-filter="save" lay-submit="">修改管理员信息</button></div>
            </div>
        </div>
    </body>
</html>
<script>
    layui.use(['table','jquery','layer'], function(){
        var table = layui.table;
        var $=layui.jquery;
        layer = layui.layer;
        $.ajax({
            type:'POST',
            url:"http://localhost:8080/api/find",
            data:{"id":sessionStorage.getItem("aid")},
            headers:{
                token:localStorage.getItem("token")
            },
            datatype: "json",
            success:function (data){
                let aid=sessionStorage.getItem("aid")
                let aname=sessionStorage.getItem("aname")
                let asex=sessionStorage.getItem("asex")
                let aage=sessionStorage.getItem("aage")
                let aphone=sessionStorage.getItem("aphone")
                let type=sessionStorage.getItem("astate")
                $("#aid").val(aid);
                $("#aname").val(aname);
                $("#asex").val(asex);
                $("#aage").val(aage);
                $("#aphone").val(aphone);
                $("#type").val(type);
            }
        })
    })

    $("#butt").click(function (){
        layui.use(['table','jquery','layer'], function(){
            var table = layui.table;
            var $=layui.jquery;
            var layer=layui.layer;

            let aid=$("#aid").val();
            let aname=$("#aname").val();
            let asex=$("#asex").val();
            let aage=$("#aage").val();
            let aphone=$("#aphone").val();
            let type=$("#type").val();
            $.ajax({
                type:"POST",
                url:"http://localhost:8080/api/update",
                data:{"aId":aid,"aName":aname,"aSex":asex,"aAge":aage,"aPhone":aphone,"aState":type},
                headers:{
                    token:localStorage.getItem("token")
                },
                datatype: "json",
                success:function (data){

                    if (data!=""){
                        var index = parent.layer.getFrameIndex(window.name);
                        layer.msg('管理员信息修改成功!',{
                            icon:1
                            ,time:800
                        },function (){
                            parent.layer.close(index);//关闭当前页
                        });
                    }
                }
            })
        })
    })
</script>
